'use strict';

const Service = require('egg').Service;
const jwt = require('jsonwebtoken');

class PermissionService extends Service {
  createToken(data) {
    const { secret, expiresIn } = this.app.config.jwt;
    const token = jwt.sign(data, secret, {
      expiresIn,
    });
    return token;
  }

  verifyToken(token) {
    return jwt.verify(token, this.app.config.jwt.secret);
  }


}

module.exports = PermissionService;
